package com.practice.library.Service;

import com.practice.library.Dao.BookDao;
import com.practice.library.Model.BookInfo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import org.springframework.stereotype.Service;

import java.util.List;
@Service
public class BookService {
    @Autowired
    private BookDao bookDao;

   // private  BookDao bookDao=new BookDao();
    public List<BookInfo> getList() {
        //没有数据,采用mock(模拟)的方式
        //采用集合的形式来进行存储

        List<BookInfo> bookInfos =bookDao.mockData();
        //根据条件依次判断集合中的内容
        for (BookInfo bookInfo:bookInfos){
            if (bookInfo.getState()==1) {
                bookInfo.setStateCN("可借阅");
            }else {
                bookInfo.setStateCN("不可借阅");
            }
        }
        return bookInfos;
    }
}

